package com.ruoyi.project.mahjong.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.mahjong.domain.TSettlement;
import com.ruoyi.project.mahjong.service.ITSettlementService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 结算列Controller
 * 
 * @author ruoyi
 * @date 2023-07-18
 */
@RestController
@RequestMapping("/mahjong/settlement")
public class TSettlementController extends BaseController
{
    @Autowired
    private ITSettlementService tSettlementService;

    /**
     * 查询结算列列表
     */
    @PreAuthorize("@ss.hasPermi('mahjong:settlement:list')")
    @GetMapping("/list")
    public TableDataInfo list(TSettlement tSettlement)
    {
        startPage();
        List<TSettlement> list = tSettlementService.selectTSettlementList(tSettlement);
        return getDataTable(list);
    }

    /**
     * 导出结算列列表
     */
    @PreAuthorize("@ss.hasPermi('mahjong:settlement:export')")
    @Log(title = "结算列", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TSettlement tSettlement)
    {
        List<TSettlement> list = tSettlementService.selectTSettlementList(tSettlement);
        ExcelUtil<TSettlement> util = new ExcelUtil<TSettlement>(TSettlement.class);
        return util.exportExcel(list, "settlement");
    }

    /**
     * 获取结算列详细信息
     */
    @PreAuthorize("@ss.hasPermi('mahjong:settlement:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tSettlementService.selectTSettlementById(id));
    }

    /**
     * 新增结算列
     */
    @PreAuthorize("@ss.hasPermi('mahjong:settlement:add')")
    @Log(title = "结算列", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TSettlement tSettlement)
    {
        return toAjax(tSettlementService.insertTSettlement(tSettlement));
    }

    /**
     * 修改结算列
     */
    @PreAuthorize("@ss.hasPermi('mahjong:settlement:edit')")
    @Log(title = "结算列", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TSettlement tSettlement)
    {
        return toAjax(tSettlementService.updateTSettlement(tSettlement));
    }

    /**
     * 删除结算列
     */
    @PreAuthorize("@ss.hasPermi('mahjong:settlement:remove')")
    @Log(title = "结算列", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tSettlementService.deleteTSettlementByIds(ids));
    }
}
